package com.wt.工厂模式;


public class factory {
    interface A{
        void color();
    }
    static class B implements A{

        @Override
        public void color() {
            System.out.println("红色");
        }
    }
    static class C implements A{

        @Override
        public void color() {
            System.out.println("黑色");
        }
    }
    static class D implements A{

        @Override
        public void color() {
            System.out.println("绿色");
        }
    }
    static A Friut(String name){
        if("red".equals(name)){
            return new B();
        }else if("green".equals(name)){
            return new D();
        }else if("black".equals(name)){
            return new C();
        }else{
            return null;
        }
    }
    public static void main(String[] args) {
        A green = factory.Friut("green");
        green.color();
    }
}
